<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>layout后台布局 - Layui</title>
<link rel="stylesheet" href="../layui/css/layui.css">
<link rel="stylesheet" href="../css/admin.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <!-- 头部区域（可配合layui已有的水平导航） -->
     <?php require "public/header.php";?>
  </div>
  <div class="layui-side layui-bg-black">
     <?php require "public/left.php";?>
  </div>
  <div class="layui-body">   
    <table class="table table-hover" id="list"> 
      <tr>
          <th width="145">选择</th>
          <th width="45">ID</th>                       
          <th width="550">内容</th>
          <th width="100">留言者</th>
          <th width="250">标题</th>
          <th width="50" >所属类</th>
          <th width="200">发布时间</th>
          <th width="200">审核状态</th>
          <th width="220">操作</th>
      </tr>
      <?php 
       
        foreach($str1 as $v){ 
      ?>                 
        <tr>
          <td><input type="checkbox"  value="<?php echo $v['id']; ?>"  /></td>
          <td><?php echo $v["id"] ?></td>                      
          <td><?php 
          $con=strip_tags($v["message"]);                        
           echo substr($con,0,60)."......";                     
          ?></td>
          <td><?php echo $v["username"]; ?></td>                     
          <td><?php echo $v["title"]; ?></td>
          <td><?php echo $v["king"]; ?></td>                       
          <td><?php echo date('Y-m-d H:i:s', $v['time']); ?></td>
          <td>
            <div class="layui-input-block" style="margin-left: -4px">
              <select name="interest" lay-filter="aihao" class="xuan">
             <?php
            if($v["flag"]==1){
             ?>
                <option value="1" selected>通过</option>
                <option value="0" >未通过</option>
                <?php
              }else{
               ?>
                <option value="1">通过</option>
                <option value="0" selected>未通过</option>
              <?php
                 }
                ?>
             </select>                        
            </div>
          </td>
          <td><a href="message_change.php?id=<?php echo $v['id']; ?>">修改</a> <a class="button border-yellow button-little" href="./delemessage.php?id=<?php echo $v['id']; ?>" onclick="{
                      if (confirm('确认删除?')) {
                          return true;
                      }
                      return false;
                  }">删除</a></td>
        </tr>
        <?php
        }
        ?>      
    </table>
    <table class="table-page">
     <tr>  
      <th>共<?php echo $total ?> 条记录</th>
      <th>当前为第&nbsp<span style="color:red"><?php echo $cpage?></span>/<?php echo $pagenum ?>&nbsp页</th>
      <th>
        <?php if($cpage==1){
          echo "首页";
        }else{
          echo "<a href='{$url}?page=1'>首页</a>";
        }
        ?>
      </th>
      <th><?php  echo "<a href='{$url}?page={$next}'>下一页</a>"?></th>
      <th><?php  echo "<a href='{$url}?page={$prev}'>上一页</a>"?></th>
      <th><?php 
      if($cpage==$pagenum) {
        echo "尾页";
      }else{
      echo "<a href='{$url}?page={$pagenum}'>尾页</a>";
       }
      ?>
      </th>                 
     </tr>
    </table>             
  </div>
  <div class="layui-footer">
    <!-- 底部固定区域 -->
  </div>
</div>
<script src="../layui/layui.js"></script>
<script type="text/javascript" src="../js/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
    $(function(){
      $('.xuan').change(function(){
        var flag = $(this).val();
        var tr = $(this).parents('tr');
        var id = tr.find("td").eq(1).html();        
        $.ajax({
          url:'message_ajax.php',
          type:'post',
          data:{'id':id,'flag':flag},
          dataType:'text',
          success:function(d){
            if(d==1){
             // alert("修改成功");             
             window.location.reload();
            }else{
              alert('修改失败');
            }
          }
        })
      })
    })

</script>
<script>
layui.use('element','from' function(){
  var from    = layui.from()
     ,element = layui.element(); //导航的hover效果、二级菜单等功能，需要依赖element模块
  
});

</script>
</body>
</html>